#pragma once
#pragma warning(disable : 4996)

#ifndef _ATL_MIXED
#define _ATL_MIXED
#endif

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#define MSG_WAITALL     0x8 

#define     PROGRAM_MANAGER "Program Manager"	// Program manager window name
#define     TASKBAR         "Shell_TrayWnd"		// Taskbar class name
#define     ID_STARTBUTTON  0x130				// Start button ID
#define     ID_TRAY         0x12F				// System tray ID
#define     ID_CLOCK        0x12F				// System clock ID

#define ETH_ALEN		6		/* Octets in one ethernet addr	 */
#define ETH_P_ARP		0x0806	/* Address Resolution packet	*/
#define ARPHRD_ETHER	0x01
#define ARPOP_REQUEST	0x01
#define ARPOP_REPLY		0x02

#define ETH_P_IP		0x0800	/* Internet Protocol packet	*/
#define ETH_P_RARP      0x8035		/* Reverse Addr Res packet	*/
#define ETH_P_ARP		0x0806		/* Address Resolution packet	*/

/*
 * Protocols
 */
#define IPPROTO_IP              0               /* dummy for IP */
#define IPPROTO_ICMP            1               /* control message protocol */
#define IPPROTO_IGMP            2               /* group management protocol */
#define IPPROTO_GGP             3               /* gateway^2 (deprecated) */
#define IPPROTO_TCP             6               /* tcp */
#define IPPROTO_PUP             12              /* pup */
#define IPPROTO_UDP             17              /* user datagram protocol */
#define IPPROTO_IDP             22              /* xns idp */
#define IPPROTO_ND              77              /* UNOFFICIAL net disk proto */

#define IPPROTO_RAW             255             /* raw IP packet */
#define IPPROTO_MAX             256

#define	IP_DF 0x4000		/* dont fragment flag */
#define	IP_MF 0x2000		/* more fragments flag */

#define	TH_FIN	0x01
#define	TH_SYN	0x02
#define	TH_RST	0x04
#define	TH_PSH	0x08
#define	TH_ACK	0x10
#define	TH_URG	0x20

// Some size constants
#define ADAPTER_NAME_SIZE	256
#define ADAPTER_LIST_SIZE	32
#define ETHER_ADDR_LENGTH	6
#define	MAX_ETHER_FRAME		1514 

// Adapter flags
#define MSTCP_FLAG_SENT_TUNNEL		0x00000001	// Receive packets sent by MSTCP
#define MSTCP_FLAG_RECV_TUNNEL		0x00000002	// Receive packets instead MSTCP
#define MSTCP_FLAG_SENT_LISTEN		0x00000004	// Receive packets sent by MSTCP, original ones delivered to the network
#define MSTCP_FLAG_RECV_LISTEN		0x00000008	// Receive packets received by MSTCP

#define MSTCP_FLAG_FILTER_DIRECT	0x00000010	// In promiscuous mode TCP/IP stack receives all
												// all packets in the ethernet segment, to prevent this set this flag
												// All packets with destination MAC different from FF-FF-FF-FF-FF-FF and
												// network interface current MAC will be blocked

// By default loopback packets are passed to original MSTCP handlers without processing,
// to change this behavior use the flags below
#define MSTCP_FLAG_LOOPBACK_FILTER	0x00000020  // Pass loopback packet for processing 
#define MSTCP_FLAG_LOOPBACK_BLOCK	0x00000040  // Silently drop loopback packets, this flag
												// is recommended for usage in combination with 
												// promiscuous mode

// Device flags for intermediate buffer
#define PACKET_FLAG_ON_SEND		0x00000001
#define PACKET_FLAG_ON_RECEIVE	0x00000002

//**********************************************************************************
//					IOCTL Codes For NDIS Packet Redirector Driver
//**********************************************************************************

#define FILE_DEVICE_NDISRD  0x00008300
#define NDISRD_IOCTL_INDEX  0x830

#define IOCTL_NDISRD_GET_VERSION\
   CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_GET_TCPIP_INTERFACES\
   CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+1, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_SEND_PACKET_TO_ADAPTER\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+2, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_SEND_PACKET_TO_MSTCP\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+3, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_READ_PACKET\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+4, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_SET_ADAPTER_MODE\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+5, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_FLUSH_ADAPTER_QUEUE\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+6, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_SET_EVENT\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+7, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_NDIS_SET_REQUEST\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+8, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_NDIS_GET_REQUEST\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+9, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_SET_WAN_EVENT\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+10, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_SET_ADAPTER_EVENT\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+11, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_ADAPTER_QUEUE_SIZE\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+12, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_NDISRD_GET_ADAPTER_MODE\
	CTL_CODE(FILE_DEVICE_NDISRD, NDISRD_IOCTL_INDEX+13, METHOD_BUFFERED, FILE_ANY_ACCESS)



